#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define rep(i, x, y) for(int i = (x); i <= (y); i++) 
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

int read() {
	int x = 0; bool f = 0; char ch = getchar(); while(!isdigit(ch)) f |= ch == '-', ch = getchar(); 
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar(); return f ? -x : x;
}

const int N = 2e5 + 10;

char s[N];
int K, m, n, a[N], b[N], c[N], ans[N];

int main() {
#ifndef ONLINE_JUDGE
	freopen("1.in", "r", stdin);
#endif
    K = in, m = in; scanf("%s", s + 1); n = in;
	rep(i, 1, n) a[i] = in + 1, b[i] = in, c[i] = in + 1;
	rep(i, 1, K) ans[i] = i;
	per(i, n, 1) {
		int l = b[i] - a[i] + 1;
		rep(j, 1, K) {
			if(ans[j] >= c[i] && ans[j] < c[i] + l) ans[j] = ans[j] - c[i] + a[i];
			else if(ans[j] >= c[i] + l) ans[j] -= l;
		}
	}
	rep(i, 1, K) putchar(s[ans[i]]); puts("");
	return 0;
}
